package cadastro;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import principal.JFPrincipal;

import javax.swing.ImageIcon;
import javax.swing.border.EmptyBorder;

@SuppressWarnings("serial")
public class JIFConta extends JDialog {

	private JPanel contentPane;
	private JPanel fieldPane;
	private JPanel buttonPane;
	private JTable table;

	public JIFConta(JFPrincipal fPrincipal) throws ClassNotFoundException,
			SQLException {
		super(fPrincipal);
		setBounds(100, 100, 450, 300);
		setTitle("Ger\u00EAncia de Contas");
		setLocationRelativeTo(this);
		setModal(true);

		contentPane = new JPanel(new BorderLayout());
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		

		fieldPane = new JPanel(new BorderLayout());
		contentPane.add(fieldPane, BorderLayout.CENTER);
		
		JScrollPane scrollPane = new JScrollPane();
		fieldPane.add(scrollPane, BorderLayout.CENTER);

		table = new JTable();
		scrollPane.setViewportView(table);

		buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5));
		contentPane.add(buttonPane, BorderLayout.SOUTH);
		
		JButton btnNovo = new JButton("Novo");
		btnNovo.setContentAreaFilled(false);
		btnNovo.setIcon(new ImageIcon(JIFConta.class.getResource("/img/textfield.png")));
		btnNovo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
			}
		});
		btnNovo.setMnemonic('N');
		buttonPane.add(btnNovo);

		JButton btnEditar = new JButton("Editar");
		btnEditar.setContentAreaFilled(false);
		btnEditar.setIcon(new ImageIcon(JIFConta.class.getResource("/img/textfield_rename.png")));
		btnEditar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			
			}
		});
		btnEditar.setMnemonic('E');
		buttonPane.add(btnEditar);

		JButton btnExcluir = new JButton("Excluir");
		btnExcluir.setContentAreaFilled(false);
		btnExcluir.setIcon(new ImageIcon(JIFConta.class.getResource("/img/delete.png")));
		btnExcluir.setMnemonic('X');
		buttonPane.add(btnExcluir); 
		
		listar();
	}
	
	public void listar(){
		//table.setModel(new ContaTableModel(cc.findListAll()));
	}
}
